package com.ruoyi.module.memberOrganizational.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.module.memberOrganizational.mapper.MemberOrganizationalMapper;
import com.ruoyi.module.memberOrganizational.domain.MemberOrganizational;
import com.ruoyi.module.memberOrganizational.service.IMemberOrganizationalService;

import javax.annotation.Resource;

/**
 * 组织架构Service业务层处理
 * 
 * @author yqq
 * @date 2024-07-09
 */
@Service
public class MemberOrganizationalServiceImpl implements IMemberOrganizationalService 
{
    @Resource
    private MemberOrganizationalMapper memberOrganizationalMapper;

    /**
     * 查询组织架构
     * 
     * @param organizationalId 组织架构主键
     * @return 组织架构
     */
    @Override
    public MemberOrganizational selectMemberOrganizationalByOrganizationalId(Long organizationalId)
    {
        return memberOrganizationalMapper.selectMemberOrganizationalByOrganizationalId(organizationalId);
    }

    /**
     * 查询组织架构列表
     * 
     * @param memberOrganizational 组织架构
     * @return 组织架构
     */
    @Override
    public List<MemberOrganizational> selectMemberOrganizationalList(MemberOrganizational memberOrganizational)
    {
        Long userId = SecurityUtils.getLoginUser().getUserId();
        memberOrganizational.setCreateBy(String.valueOf(userId));
        return memberOrganizationalMapper.selectMemberOrganizationalList(memberOrganizational);
    }

    /**
     * 新增组织架构
     * 
     * @param memberOrganizational 组织架构
     * @return 结果
     */
    @Override
    public int insertMemberOrganizational(MemberOrganizational memberOrganizational)
    {
        Long userId = SecurityUtils.getLoginUser().getUserId();
        memberOrganizational.setCreateBy(String.valueOf(userId));
        memberOrganizational.setCreateTime(DateUtils.getNowDate());
        return memberOrganizationalMapper.insertMemberOrganizational(memberOrganizational);
    }

    /**
     * 修改组织架构
     * 
     * @param memberOrganizational 组织架构
     * @return 结果
     */
    @Override
    public int updateMemberOrganizational(MemberOrganizational memberOrganizational)
    {
        memberOrganizational.setUpdateTime(DateUtils.getNowDate());
        return memberOrganizationalMapper.updateMemberOrganizational(memberOrganizational);
    }

    /**
     * 批量删除组织架构
     * 
     * @param organizationalIds 需要删除的组织架构主键
     * @return 结果
     */
    @Override
    public int deleteMemberOrganizationalByOrganizationalIds(Long[] organizationalIds)
    {
        return memberOrganizationalMapper.deleteMemberOrganizationalByOrganizationalIds(organizationalIds);
    }

    /**
     * 删除组织架构信息
     * 
     * @param organizationalId 组织架构主键
     * @return 结果
     */
    @Override
    public int deleteMemberOrganizationalByOrganizationalId(Long organizationalId)
    {
        return memberOrganizationalMapper.deleteMemberOrganizationalByOrganizationalId(organizationalId);
    }
}
